package edu.byu.intex2.data.dao;

import edu.byu.intex2.data.dao.*;
import java.sql.*;
import java.util.*;

/*******************************************************************************
 *
 *        @author Adam
 *          Date: Mar 3, 2009
 *   Description:
 * Last Revision: Mar 3, 2009
 *
 ******************************************************************************/

public class Service extends BusinessObject {

    private Timestamp sedate = null;
    private double totalprice = 0;
    private double tax = 0;
    private String customerid = null;
    private String technicianid = null;
    private String physicalcarid = null;
    private String servicefacilityid = null;
    private Customer customer = null;
    private Technician technician = null;
    private PhysicalCar physicalcar = null;
    private ServiceFacility servicefacility = null;
    private List selList = null;

    /** Creates a new instance of the BO */
    public Service(String id) {
      super(id);
    }

    /** Convenience method to call the correct DAO to save this business object */
    public void save() throws DataException {
      ServiceDAO.getInstance().save(this);
    }

    /** Returns a string representation of the object */
    public String toString() {
      return getId();
    }

    /**
     * @return the sedate
     */
    public Timestamp getSedate() {
        return sedate;
    }

    /**
     * @param sedate the sedate to set
     */
    public void setSedate(Timestamp sedate) {
        this.sedate = sedate;
        this.setDirty();
    }

    /**
     * @return the totalprice
     */
    public double getTotalprice() {
        return totalprice;
    }

    /**
     * @param totalprice the totalprice to set
     */
    public void setTotalprice(double totalprice) {
        this.totalprice = totalprice;
        this.setDirty();
    }

    /**
     * @return the tax
     */
    public double getTax() {
        return tax;
    }

    /**
     * @param tax the tax to set
     */
    public void setTax(double tax) {
        this.tax = tax;
        this.setDirty();
    }

    /**
     * @return the customerid
     */
    public String getCustomerid() {
        return customerid;
    }

    /**
     * @param customerid the customerid to set
     */
    public void setCustomerid(String customerid) {
        this.customerid = customerid;
        this.setDirty();
    }
    
    /**
     * @return the technicianid
     */
    public String getTechnicianid() {
        return technicianid;
    }

    /**
     * @param technicianid the technicianid to set
     */
    public void setTechnicianid(String salespersonid) {
        this.technicianid = technicianid;
        this.setDirty();
    }
    
    /**
     * @return the physicalcarid
     */
    public String getPhysicalcarid() {
        return physicalcarid;
    }

    /**
     * @param physicalcarid the physicalcarid to set
     */
    public void setPhysicalcarid(String physicalcarid) {
        this.physicalcarid = physicalcarid;
        this.setDirty();
    }

     /**
     * @return the servicefacilityid
     */
    public String getServiceFacilityid() {
        return servicefacilityid;
    }

    /**
     * @param dealershipid the dealershipid to set
     */
    public void setServiceFacilityid(String servicefacilityid) {
        this.servicefacilityid = servicefacilityid;
        this.setDirty();
    }

    /**
     * @return the customer
     */
    public Customer getCustomer() throws DataException {
        if(customer == null){
            customer = CustomerDAO.getInstance().read(this.id);
        }
        return customer;
    }

    /**
     * @param customer the customer to set
     */
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

     /**
     * @return the technician
     */
    public Technician getTechnician() throws DataException {
        if(technician == null){
            technician = TechnicianDAO.getInstance().read(this.id);
        }
        return technician;
    }

    /**
     * @param technician the technician to set
     */
    public void setTechnician(Technician technician) {
        this.technician = technician;
    }

    /**
     * @return the physicalcar
     */
    public PhysicalCar getPhysicalcar() throws DataException {
        if (physicalcar == null) {
            physicalcar = PhysicalCarDAO.getInstance().read(this.id);
        }
        return physicalcar;
    }

    /**
     * @param physicalcar the physicalcar to set
     */
    public void setPhysicalcar(PhysicalCar physicalcar) {
        this.physicalcar = physicalcar;
        this.setDirty();
    }

     /**
     * @return the servicefacility
     */
    public ServiceFacility getServiceFacility() throws DataException {
        if(servicefacility == null){
            servicefacility = ServiceFacilityDAO.getInstance().read(this.id);
        }
        return servicefacility;
    }

    /**
     * @param servicefacility the servicefacility to set
     */
    public void setServiceFacility(ServiceFacility servicefacility) {
        this.servicefacility = servicefacility;
    }

        /**
     * @return the selList
     */
    public List getSelList() throws DataException {
        if(this.selList == null){
            this.selList = ServiceLineDAO.getInstance().getBy("serviceid", this.id);
        }
        return selList;
    }

    /**
     * @param selList the seList to set
     */
    public void setSelList(List selList) {
        this.selList = selList;
    }

}//class